﻿<UserControl 
    Visibility="Collapsed"
    x:Class="HeritageAcademy.Library.Controls.TableOfContentsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:Controls="clr-namespace:HeritageAcademy.Library.Controls"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <Storyboard x:Key="Open">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FlyoutGrid" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.07" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FlyoutGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.8"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.20" Value="1" KeySpline="0,1,0.51,1"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FlyoutGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.8"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.20" Value="1" KeySpline="0,1,0.51,1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Close">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FlyoutGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                <SplineDoubleKeyFrame KeySpline="0.49,0,1,0" KeyTime="00:00:00.2500000" Value="0.7"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FlyoutGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                <SplineDoubleKeyFrame KeySpline="0.49,0,1,0" KeyTime="00:00:00.2500000" Value="0.7"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FlyoutGrid" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="1"/>
                <SplineDoubleKeyFrame KeyTime="00:00:00.2500000" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>

    <Canvas Width="0" Height="0">
        <Rectangle Width="20000" Height="20000" Fill="#0000" Canvas.Top="-10000" Canvas.Left="-10000"  MouseLeftButtonDown="Rectangle_MouseLeftButtonDown" />

        <Grid x:Name="FlyoutGrid" RenderTransformOrigin="0,0" SnapsToDevicePixels="True" Canvas.Top="0" Canvas.Left="0" >
            <Grid.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </Grid.RenderTransform>
            <Grid Margin="0,8,10,8">
                <Border>
                    <Border.Effect>
                        <BlurEffect Radius="10" RenderingBias="Quality"/>
                    </Border.Effect>
                    <Controls:CalloutShape x:Name="MediumShadow" ArrowAlignment="Left" ArrowHeight="30" ArrowPlacement="Top" ArrowWidth="30" StrokeThickness="0" Margin="4,0,8,2" RenderTransformOrigin="0.507,0.861" Fill="#90000000">
                        <Controls:CalloutShape.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform AngleY="3.5"/>
                                <RotateTransform/>
                                <TranslateTransform Y="8.0"/>
                            </TransformGroup>
                        </Controls:CalloutShape.RenderTransform>
                    </Controls:CalloutShape>
                </Border>
            </Grid>

            <Controls:CalloutShape ArrowAlignment="Left" ArrowHeight="30" ArrowPlacement="Top" ArrowWidth="30" StrokeThickness="0" Margin="0,0,0,11" Fill="{DynamicResource SoftDarkUIBrush}" />

            <!-- Content Area -->
            <Grid Width="325" Margin="0,32,0,14">
                <Grid.Resources>

                    <!-- Separator -->

                    <Style TargetType="Separator">
                        <Setter Property="Margin" Value="0" />
                        <Setter Property="SnapsToDevicePixels" Value="True" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="Separator">
                                    <StackPanel>
                                        <Rectangle Height="1" Fill="#50000000" />
                                        <Rectangle Height="1" Fill="#18FFFFFF" />
                                    </StackPanel>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <!-- RadioButton -->

                    <Style TargetType="RadioButton">
                        <Setter Property="OverridesDefaultStyle" Value="True" />
                        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                        <Setter Property="SnapsToDevicePixels" Value="True" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="RadioButton">
                                    <Border x:Name="Border" Background="Transparent" BorderBrush="Transparent" BorderThickness="0,2,0,1"  >
                                        <ContentPresenter Margin="{TemplateBinding Padding}" />
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource LogoBackgroundBrush}" />
                                        </Trigger>
                                        <Trigger Property="IsFocused" Value="True">
                                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource LogoBackgroundBrush}" />
                                        </Trigger>
                                        <Trigger Property="IsChecked" Value="True">
                                            <Setter TargetName="Border" Property="Background" Value="Transparent" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <!-- Expander -->

                    <Style TargetType="Expander">
                        <Setter Property="OverridesDefaultStyle" Value="True" />
                        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                        <Setter Property="SnapsToDevicePixels" Value="True" />
                        <Setter Property="Padding" Value="0" />
                        <Setter Property="Foreground" Value="White" />
                        <Setter Property="MinHeight" Value="36" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="Expander">
                                    <StackPanel x:Name="StackPanel" Margin="0,0,0,0">
                                        <Border x:Name="HeaderBorder" Cursor="Hand" Background="Transparent">
                                            <Grid Margin="16,8">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="16" />
                                                    <ColumnDefinition Width="*" />
                                                </Grid.ColumnDefinitions>
                                                <Path x:Name="Arrow" Margin="0,1,0,0" Width="7" Height="9" Data="{StaticResource RightArrow}" Fill="#60FFFFFF" Stretch="Fill" HorizontalAlignment="Left">
                                                    <Path.LayoutTransform>
                                                        <RotateTransform x:Name="ArrowRotator" Angle="0" />
                                                    </Path.LayoutTransform>
                                                </Path>
                                                <ContentPresenter Grid.Column="1" ContentSource="Header" Margin="0,0,0,0" TextElement.FontSize="14" TextElement.FontWeight="Bold" />
                                            </Grid>
                                        </Border>
                                        <Controls:Reveal x:Name="Reveal" Duration="200">
                                            <ContentPresenter x:Name="ContentHost" ContentSource="Content" Margin="0,0,0,8" Width="{Binding ElementName=StackPanel, Path=ActualWidth}" />
                                        </Controls:Reveal>
                                    </StackPanel>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsExpanded" Value="True">
                                            <Trigger.EnterActions>
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <DoubleAnimation Storyboard.TargetName="ArrowRotator" Storyboard.TargetProperty="Angle" To="90" Duration="00:00:00.1" />
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </Trigger.EnterActions>
                                            <Trigger.ExitActions>
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <DoubleAnimation Storyboard.TargetName="ArrowRotator" Storyboard.TargetProperty="Angle" Duration="00:00:00.1" />
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </Trigger.ExitActions>
                                            <Setter TargetName="Reveal" Property="IsExpanded" Value="True" />
                                            <Setter TargetName="HeaderBorder" Property="Cursor" Value="Arrow" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <!-- Button -->

                    <Style TargetType="Button">
                        <Setter Property="OverridesDefaultStyle" Value="True" />
                        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                        <Setter Property="SnapsToDevicePixels" Value="True" />
                        <Setter Property="Foreground" Value="White" />
                        <Setter Property="FontSize" Value="14" />
                        <Setter Property="FontWeight" Value="Bold" />
                        <Setter Property="MinHeight" Value="38" />
                        <Setter Property="Padding" Value="16,7,8,7" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="Button">
                                    <Border x:Name="Border" Cursor="Hand" Background="Transparent" BorderBrush="Transparent" BorderThickness="0,1">
                                        <ContentPresenter Margin="{TemplateBinding Padding}" VerticalAlignment="Center" />
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource LogoBackgroundBrush}" />
                                        </Trigger>
                                        <Trigger Property="IsFocused" Value="True">
                                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource LogoBackgroundBrush}" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <!-- ScrollBar -->

                    <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
                        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                        <Setter Property="OverridesDefaultStyle" Value="true"/>
                        <Setter Property="IsTabStop" Value="false"/>
                        <Setter Property="Focusable" Value="false"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type RepeatButton}">
                                    <Border Background="Transparent"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                    <Style x:Key="HorizontalScrollBarThumb" TargetType="{x:Type Thumb}">
                        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                        <Setter Property="OverridesDefaultStyle" Value="true"/>
                        <Setter Property="IsTabStop" Value="false"/>
                        <Setter Property="Focusable" Value="false"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Thumb}">
                                    <Grid Background="Transparent">
                                        <Border Height="8" Background="#FFFFFF" BorderThickness="0.5,1" CornerRadius="3"/>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                    <Style x:Key="VerticalScrollBarThumb" TargetType="{x:Type Thumb}">
                        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                        <Setter Property="OverridesDefaultStyle" Value="true"/>
                        <Setter Property="IsTabStop" Value="false"/>
                        <Setter Property="Focusable" Value="false"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Thumb}">
                                    <Grid Background="Transparent">
                                        <Border Width="8" Background="#FFFFFF" BorderThickness="1,0.5" CornerRadius="3" HorizontalAlignment="Left"/>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                    <ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
                        <Grid Width="16">
                            <Track Name="PART_Track" IsDirectionReversed="true">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Command="ScrollBar.PageUpCommand" Style="{StaticResource ScrollBarPageButton}"/>
                                </Track.DecreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb x:Name="Thumb" Opacity="0.15" Style="{StaticResource VerticalScrollBarThumb}"/>
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Command="ScrollBar.PageDownCommand" Style="{StaticResource ScrollBarPageButton}"/>
                                </Track.IncreaseRepeatButton>
                            </Track>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Trigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Duration="0:0:0.25" Storyboard.TargetName="Thumb" Storyboard.TargetProperty="Opacity" To="1"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Duration="0:0:0.25" Storyboard.TargetName="Thumb" Storyboard.TargetProperty="Opacity"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.ExitActions>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                    <ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
                        <Grid Height="26">
                            <Border Height="6" Background="#18000000" CornerRadius="3"/>
                            <Track Name="PART_Track" IsDirectionReversed="false">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Command="ScrollBar.PageUpCommand" Style="{StaticResource ScrollBarPageButton}"/>
                                </Track.DecreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb x:Name="Thumb" Opacity="0.25" Style="{StaticResource HorizontalScrollBarThumb}"/>
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Command="ScrollBar.PageDownCommand" Style="{StaticResource ScrollBarPageButton}"/>
                                </Track.IncreaseRepeatButton>
                            </Track>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Trigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Duration="0:0:0.25" Storyboard.TargetName="Thumb" Storyboard.TargetProperty="Opacity" To="1"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Duration="0:0:0.25" Storyboard.TargetName="Thumb" Storyboard.TargetProperty="Opacity"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.ExitActions>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                    <Style TargetType="{x:Type ScrollBar}">
                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                        <Setter Property="OverridesDefaultStyle" Value="true"/>
                        <Setter Property="Template" Value="{StaticResource VerticalScrollBar}"/>
                        <Style.Triggers>
                            <Trigger Property="Orientation" Value="Horizontal">
                                <Setter Property="Template" Value="{StaticResource HorizontalScrollBar}"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>

                    <Style TargetType="{x:Type ScrollViewer}">
                        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                        <Setter Property="OverridesDefaultStyle" Value="True"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                    <Grid>
                                        <ScrollContentPresenter Grid.Column="1"/>
                                        <ScrollBar Name="PART_VerticalScrollBar" Maximum="{TemplateBinding ScrollableHeight}" Value="{TemplateBinding VerticalOffset}" ViewportSize="{TemplateBinding ViewportHeight}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" HorizontalAlignment="Right"/>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <Style x:Key="ActionButton" TargetType="Button">
                        <Setter Property="OverridesDefaultStyle" Value="True"/>
                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                        <Setter Property="Padding" Value="0,0,0,0"/>
                        <Setter Property="Cursor" Value="Hand"/>
                        <Setter Property="MinHeight" Value="36"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="Button">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Border x:Name="MouseOverBorder" CornerRadius="2" BorderThickness="0,1" Grid.ColumnSpan="2" Opacity="0" Background="{DynamicResource LogoBackgroundBrush}" />

                                        <ContentPresenter x:Name="ContentHost" Margin="0,0,20,0" VerticalAlignment="Center"/>
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Trigger.EnterActions>
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <DoubleAnimation Storyboard.TargetName="MouseOverBorder" Storyboard.TargetProperty="Opacity" To="1" Duration="00:00:00" />
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </Trigger.EnterActions>
                                            <Trigger.ExitActions>
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <DoubleAnimation Storyboard.TargetName="MouseOverBorder" Storyboard.TargetProperty="Opacity" Duration="00:00:00" />
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </Trigger.ExitActions>
                                            <Setter TargetName="ContentHost" Property="Margin" Value="0" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Grid.Resources>

                <StackPanel Margin="0,0,0,0">
                    <TextBlock FontSize="14" FontWeight="Bold" Foreground="White" Text="Содержание" Margin="16,10" />

                    <Separator />

                    <Button Command="{Binding GotoBeginningCommand}" Click="Button_ClickToClose">
                        <StackPanel Orientation="Horizontal">
                            <Path Data="{DynamicResource Bookmark}" Width="8" Stretch="Uniform" MaxHeight="20" Fill="#60FFFFFF" VerticalAlignment="Center" Margin="1,1,8,-1" />
                            <TextBlock VerticalAlignment="Center" Text="Начало" FontWeight="Normal" />
                        </StackPanel>
                    </Button>
                    
                    <Separator />

                    <Button Command="{Binding GotoFurtherstLocationCommand}" Click="Button_ClickToClose">
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                            <Path Data="{DynamicResource Bookmark}" Width="8" Stretch="Uniform" MaxHeight="20" Fill="#60FFFFFF" VerticalAlignment="Center" Margin="0,1,8,-1" />
                            <TextBlock VerticalAlignment="Center" Text="Последняя прочитанная страница" FontWeight="Normal" />
                        </StackPanel>
                    </Button>
                    
                    <Separator />

                    <RadioButton x:Name="ChaptersRadioButton" IsChecked="False"  >
                        <Expander IsExpanded="{Binding ElementName=ChaptersRadioButton, Path=IsChecked, Mode=TwoWay}">
                            <Expander.Header>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock>
                                        <TextBlock Text="Главы" FontWeight="Bold" FontSize="14" />
                                        <TextBlock Text="{Binding Path=Chapters.Count}" FontWeight="Normal" Foreground="#60FFFFFF" />
                                    </TextBlock>
                                </StackPanel>
                            </Expander.Header>
                            <ScrollViewer MaxHeight="325" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
                                <ItemsControl ItemsSource="{Binding Chapters}">
                                    <ItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <Button Style="{StaticResource ActionButton}" Content="{Binding .}" FontWeight="Normal" FontSize="12"  Command="{Binding GotoChapterCommand}" Foreground="White" Click="Button_ClickToClose" Margin="0">
                                                <Button.ContentTemplate>
                                                    <DataTemplate>
                                                        <Grid Margin="20,0,0,0" HorizontalAlignment="Left" >
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="*" />
                                                                <ColumnDefinition Width="Auto" />
                                                            </Grid.ColumnDefinitions>
                                                            <TextBlock FontWeight="Normal" Foreground="White" FontSize="11"  Text="{Binding Model.Title}" TextTrimming="CharacterEllipsis" />
                                                            <TextBlock x:Name="PageNumberText" Grid.Column="1" FontWeight="Normal"  FontSize="11"  Foreground="#50FFFFFF" Text="{Binding Path=CurrentPageNumber, StringFormat='  (Страница {0})'}" />
                                                        </Grid>
                                                        <DataTemplate.Triggers>
                                                            <DataTrigger Binding="{Binding CurrentPageNumber}" Value="{x:Null}">
                                                                <Setter TargetName="PageNumberText" Property="Visibility" Value="Collapsed" />
                                                            </DataTrigger>
                                                        </DataTemplate.Triggers>
                                                    </DataTemplate>
                                                </Button.ContentTemplate>
                                            </Button>
                                        </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                </ItemsControl>
                            </ScrollViewer>
                        </Expander>
                    </RadioButton>

                    <Separator />

                    <RadioButton x:Name="BookmarksRadioButton" >
                        <Expander IsExpanded="{Binding ElementName=BookmarksRadioButton, Path=IsChecked, Mode=TwoWay}">
                            <Expander.Header>
                                <TextBlock>
                                    <TextBlock Text="Закладки и выделения" FontWeight="Bold" FontSize="14" />
                                    <TextBlock Text="{Binding Path=Bookmarks.Count}" FontWeight="Normal" Foreground="#60FFFFFF" />
                                </TextBlock>
                            </Expander.Header>
                            <ScrollViewer MaxHeight="325" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
                                <ItemsControl x:Name="BookmarkItemsControl" ItemsSource="{Binding Bookmarks}">
                                    <ItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <Button Style="{StaticResource ActionButton}" Content="{Binding .}" FontWeight="Normal" FontSize="12"  Command="{Binding GotoLocationCommand}" Foreground="White" Click="Button_ClickToClose" Margin="0">
                                                <Button.ContentTemplate>
                                                    <DataTemplate>
                                                        <Grid Margin="16,0,0,0" HorizontalAlignment="Left" >
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="Auto" />
                                                                <ColumnDefinition Width="*" />
                                                                <ColumnDefinition Width="Auto" />
                                                            </Grid.ColumnDefinitions>
                                                            <Path x:Name="Icon" Data="{DynamicResource Bookmark}" Width="6" Stretch="Uniform" MaxHeight="20" Fill="#60FFFFFF" VerticalAlignment="Center" Margin="3,0,7,0" />
                                                            <TextBlock x:Name="BookmarkText" Grid.Column="1" FontWeight="Normal" Foreground="White" FontSize="11"  Text="Закладка" TextTrimming="CharacterEllipsis" />
                                                            <TextBlock x:Name="PageNumberText" Grid.Column="2" FontWeight="Normal"  FontSize="11"  Foreground="#60FFFFFF" Text="{Binding Path=CurrentPageNumber, StringFormat='  (Страница {0})'}" />
                                                        </Grid>
                                                        <DataTemplate.Triggers>
                                                            <DataTrigger Binding="{Binding CurrentPageNumber}" Value="{x:Null}">
                                                                <Setter TargetName="PageNumberText" Property="Visibility" Value="Collapsed" />
                                                            </DataTrigger>
                                                            <DataTrigger Binding="{Binding IsHighlight}" Value="true">
                                                                <Setter TargetName="Icon" Property="Data" Value="{StaticResource Highlight}" />
                                                                <Setter TargetName="Icon" Property="Width" Value="11" />
                                                                <Setter TargetName="Icon" Property="MaxHeight" Value="11" />
                                                                <Setter TargetName="Icon" Property="Margin" Value="0,0,6,0" />
                                                                <Setter TargetName="BookmarkText" Property="Text" Value="{Binding Model.Name}" />
                                                            </DataTrigger>
                                                        </DataTemplate.Triggers>
                                                    </DataTemplate>
                                                </Button.ContentTemplate>
                                            </Button>
                                        </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                </ItemsControl>
                            </ScrollViewer>
                        </Expander>
                    </RadioButton>

                </StackPanel>

            </Grid>
        </Grid>
    </Canvas>
</UserControl>
